package cn.edu.xmist.singleton;

/**
 *懒汉式单例模式（线程安全）
 */
public class CurrentSingleton1 {
    private static CurrentSingleton1 singleton1;

    private CurrentSingleton1() {
    }

    public static CurrentSingleton1 getSingleton1() {
        // 多线程并发访问没有问题
        if (singleton1 == null) {
            synchronized (CurrentSingleton1.class) {
                if (singleton1 == null) {
                    /**
                     * 全局唯一的实例
                     */
                    singleton1 = new CurrentSingleton1();
                }
            }
        }
        return singleton1;
    }
}
